<?php
class Pagemanager_Model_Updatepagedata implements Pagemanager_Model_Mainable{
    
    private $core_controller_notnull;
    private $core_controller_tokencheckout;
    
    private $excepted_result = 1;
    
    private $pagemanager_data_updatepagesettings;
    private $pagemanager_data_updatepagemetavalues;
    private $pagemanager_data_updatepagecontentvalues;
    
    private $update_page_settings_result;
    private $update_page_meta_values_result;
    private $update_page_content_values_result;

    public function main(array $variables = null){
        $this->core_controller_notnull = new Core_Controller_Notnull;
        $this->core_controller_notnull->main($variables);
        $this->core_controller_tokencheckout = new Core_Controller_Tokencheckout;
        $this->core_controller_tokencheckout->main($variables['post']);
        
        $this->pagemanager_data_updatepagesettings = new Pagemanager_Data_Updatepagesettings;
        $this->pagemanager_data_updatepagemetavalues = new Pagemanager_Data_Updatepagemetavalues;
        $this->pagemanager_data_updatepagecontentvalues = new Pagemanager_Data_Updatepagecontentvalues;
        
        $this->update_page_settings_result = $this->pagemanager_data_updatepagesettings->main($variables);
        $this->update_page_meta_values_result = $this->pagemanager_data_updatepagemetavalues->main($variables);
        $this->update_page_content_values_result = $this->pagemanager_data_updatepagecontentvalues->main($variables);
        
        if(
                ($this->update_page_settings_result == $this->excepted_result) &&
                ($this->update_page_meta_values_result == $this->excepted_result) &&
                ($this->update_page_content_values_result == $this->excepted_result)
                ){
            header("Location: ".SITE_ROOT."zarzadzaj-stronami.html");
        }
        else {
            header("Location: ".SITE_ROOT."zarzadzaj-stronami.html");
        }
    }
    
}
